CC = gcc
XX = g++
TARGET = ../../bin/sercomm.so
MYLIB  = ../../libs/libctb/include/ctb-0.16/linux 
CFLAGS = -I$(MYLIB) -Wall -O -g -I.. -I./lib -I../smartx/include -I../../libs/libctb/include -I../../libs/libctb/src -I../../libs/lua/src -fPIC
LIBS   = ../../libs/lua/src/liblua.a -lpthread -lrt -ldl
SHARED := --shared  

%.o: %.c                                 
	$(CC) $(CFLAGS) -c $< -o $@          

%.o:%.cpp
	$(XX) $(CFLAGS) -c $< -o $@

SOURCES = $(wildcard *.c *.cpp ../smartx/include/event.cpp ../smartx/include/define.cpp ../../libs/libctb/src/fifo.cpp ../../libs/libctb/src/getopt.cpp ../../libs/libctb/src/iobase.cpp ../../libs/libctb/src/portscan.cpp ../../libs/libctb/src/linux/serport.cpp ../../libs/libctb/src/serportx.cpp ../../libs/libctb/src/linux/timer.cpp)
OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES)))  

$(TARGET) : $(OBJS)
	$(XX) $(SHARED) $(OBJS) -o $(TARGET) $(LIBS)
	chmod a+x $(TARGET)
clean:
	rm -rf *.o $(TARGET)
	rm -rf ../smartx/include/*.o
	rm -rf ../../libs/libctb/src/*.o
	rm -rf ../../libs/libctb/src/linux/*.o


































